<?php

/**
 * This is the model class for table "automatic_fire_suppression_system".
 *
 * The followings are the available columns in table 'automatic_fire_suppression_system':
 * @property integer $id
 * @property string $type_of_extinguishing_agent_used
 * @property integer $jockey_pump_capacity_hp
 * @property integer $jpc_gpm
 * @property integer $fire_pump_capacity_hp
 * @property integer $fpc_gpm
 * @property integer $tank_capacity
 * @property string $maintaining_line_pressure
 * @property string $farthest_sprinkler_head_pressure
 * @property integer $riser_size
 * @property string $type_of_head_installed
 * @property integer $no_of_head_per_floor
 * @property integer $total
 * @property integer $spacing_head
 * @property string $location_of_fire_department_connection
 * @property string $date_last_tested
 * @property string $conducted_by
 * @property string $plan_submitted
 * @property string $certificate_of_installation
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class AutomaticFireSuppressionSystem extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AutomaticFireSuppressionSystem the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'automatic_fire_suppression_system';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('jockey_pump_capacity_hp, jpc_gpm, fire_pump_capacity_hp, fpc_gpm, tank_capacity, riser_size, no_of_head_per_floor, total, spacing_head, inspection_id', 'numerical', 'integerOnly'=>true),
			array('type_of_extinguishing_agent_used, maintaining_line_pressure, farthest_sprinkler_head_pressure, type_of_head_installed, location_of_fire_department_connection, date_last_tested, conducted_by, plan_submitted, certificate_of_installation', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, type_of_extinguishing_agent_used, jockey_pump_capacity_hp, jpc_gpm, fire_pump_capacity_hp, fpc_gpm, tank_capacity, maintaining_line_pressure, farthest_sprinkler_head_pressure, riser_size, type_of_head_installed, no_of_head_per_floor, total, spacing_head, location_of_fire_department_connection, date_last_tested, conducted_by, plan_submitted, certificate_of_installation, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'type_of_extinguishing_agent_used' => 'Type Of Extinguishing Agent Used',
			'jockey_pump_capacity_hp' => 'Jockey Pump Capacity Hp',
			'jpc_gpm' => 'Jpc Gpm',
			'fire_pump_capacity_hp' => 'Fire Pump Capacity Hp',
			'fpc_gpm' => 'Fpc Gpm',
			'tank_capacity' => 'Tank Capacity',
			'maintaining_line_pressure' => 'Maintaining Line Pressure',
			'farthest_sprinkler_head_pressure' => 'Farthest Sprinkler Head Pressure',
			'riser_size' => 'Riser Size',
			'type_of_head_installed' => 'Type Of Head Installed',
			'no_of_head_per_floor' => 'No Of Head Per Floor',
			'total' => 'Total',
			'spacing_head' => 'Spacing Head',
			'location_of_fire_department_connection' => 'Location Of Fire Department Connection',
			'date_last_tested' => 'Date Last Tested',
			'conducted_by' => 'Conducted By',
			'plan_submitted' => 'Plan Submitted',
			'certificate_of_installation' => 'Certificate Of Installation',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('type_of_extinguishing_agent_used',$this->type_of_extinguishing_agent_used,true);
		$criteria->compare('jockey_pump_capacity_hp',$this->jockey_pump_capacity_hp);
		$criteria->compare('jpc_gpm',$this->jpc_gpm);
		$criteria->compare('fire_pump_capacity_hp',$this->fire_pump_capacity_hp);
		$criteria->compare('fpc_gpm',$this->fpc_gpm);
		$criteria->compare('tank_capacity',$this->tank_capacity);
		$criteria->compare('maintaining_line_pressure',$this->maintaining_line_pressure,true);
		$criteria->compare('farthest_sprinkler_head_pressure',$this->farthest_sprinkler_head_pressure,true);
		$criteria->compare('riser_size',$this->riser_size);
		$criteria->compare('type_of_head_installed',$this->type_of_head_installed,true);
		$criteria->compare('no_of_head_per_floor',$this->no_of_head_per_floor);
		$criteria->compare('total',$this->total);
		$criteria->compare('spacing_head',$this->spacing_head);
		$criteria->compare('location_of_fire_department_connection',$this->location_of_fire_department_connection,true);
		$criteria->compare('date_last_tested',$this->date_last_tested,true);
		$criteria->compare('conducted_by',$this->conducted_by,true);
		$criteria->compare('plan_submitted',$this->plan_submitted,true);
		$criteria->compare('certificate_of_installation',$this->certificate_of_installation,true);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}